import { IPSWFLink } from './ipswflink';
import { IPSWFProcess } from './ipswfprocess';
import { IPSWFVersion } from './ipswfversion';
import { IPSWorkflow } from './ipsworkflow';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSWFVersionImpl extends PSModelObjectImpl implements IPSWFVersion {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pswflinks: IPSWFLink[] | null = null;

  getPSWFLinks(): IPSWFLink[] | null {
    if (this.pswflinks == null) {
      this.pswflinks = this.fillChildListModel(this.M.getPSWFLinks, 'wf.IPSWFLink') as IPSWFLink[];
    }
    return this.pswflinks;
  }

  get psWFLinks(): IPSWFLink[] | null {
    return this.getPSWFLinks();
  }

  findPSWFLink(objKey: any): IPSWFLink | null {
    return this.getPSModel5('wf.IPSWFLink', this.getPSWFLinks(), objKey) as IPSWFLink;
  }

  protected pswfprocesses: IPSWFProcess[] | null = null;

  getPSWFProcesses(): IPSWFProcess[] | null {
    if (this.pswfprocesses == null) {
      this.pswfprocesses = this.fillChildListModel(this.M.getPSWFProcesses, 'wf.IPSWFProcess') as IPSWFProcess[];
    }
    return this.pswfprocesses;
  }

  get psWFProcesses(): IPSWFProcess[] | null {
    return this.getPSWFProcesses();
  }

  findPSWFProcess(objKey: any): IPSWFProcess | null {
    return this.getPSModel5('wf.IPSWFProcess', this.getPSWFProcesses(), objKey) as IPSWFProcess;
  }

  protected psworkflow: IPSWorkflow | null = null;

  getPSWorkflow(): IPSWorkflow | null {
    if (this.psworkflow != null) return this.psworkflow;
    const value = this.M.getPSWorkflow;
    if (value == null) {
      return null;
    }
    this.psworkflow = this.getPSModel4('wf.IPSWorkflow', value, 'getPSWorkflow') as IPSWorkflow;
    return this.psworkflow;
  }

  get psWorkflow(): IPSWorkflow | null {
    return this.getPSWorkflow();
  }

  getPSWorkflowMust(): IPSWorkflow {
    const value = this.getPSWorkflow();
    if (value == null) {
      throw new Error('未指定工作流');
    }
    return value;
  }

  protected startpswfprocess: IPSWFProcess | null = null;

  getStartPSWFProcess(): IPSWFProcess | null {
    if (this.startpswfprocess != null) return this.startpswfprocess;
    const value = this.M.getStartPSWFProcess;
    if (value == null) {
      return null;
    }
    this.startpswfprocess = this.findPSWFProcess(value);
    return this.startpswfprocess;
  }

  get startPSWFProcess(): IPSWFProcess | null {
    return this.getStartPSWFProcess();
  }

  getStartPSWFProcessMust(): IPSWFProcess {
    const value = this.getStartPSWFProcess();
    if (value == null) {
      throw new Error('未指定开始处理');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get wFCodeName(): string {
    return this.M.wFCodeName;
  }

  get wFMode(): string {
    return this.M.wFMode;
  }

  get wFVersion(): number {
    return this.M.wFVersion;
  }

  get hasMobStartView(): boolean {
    return this.M.hasMobStartView;
  }

  getHasMobStartView(): boolean {
    return this.M.hasMobStartView;
  }

  get hasStartView(): boolean {
    return this.M.hasStartView;
  }

  getHasStartView(): boolean {
    return this.M.hasStartView;
  }

  get valid(): boolean {
    return this.M.valid;
  }

  get cls(): string {
    return 'PSWFVersionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelObject' || cls == 'IPSObject' || cls == 'wf.IPSWFVersion' || cls == 'wf.IPSWorkflowObject') return true;
    return super.instanceof(cls);
  }
}
